#ifndef _AMANAGER_H_
# define _AMANAGER_H_

# include <map>
# include <string>

struct IArgs
{
protected:
	IArgs() {};
	virtual ~IArgs() {};
};

template<typename T>
class AManager
{
public:
	struct Element;
	typedef typename bool (*MngrFunc)(Element*, IArgs*);
public:
	struct Element
	{
		T*			Object;
		IArgs*		Datas;
		bool		Delete;

		Element(T* _object, IArgs* _datas, bool _delete = false);
		~Element();
	};
protected:
	typedef std::pair<Element*, MngrFunc> Pair;
	typedef typename std::map< std::string, Pair> Elements;
	Elements m_elements;

public:
	AManager();
	virtual ~AManager();

	virtual void Add(std::string const& _name, T* _element,
					 MngrFunc _func, IArgs* _datas = NULL);
	virtual void Manage(IArgs*) = 0;
	void GetElements(std::list<T*>& _out);

	T* operator[](std::string const& _name);
};

# include "amanager.tpp"

#endif // _AMANAGER_H_